package edu.sctu.zhuyingzhi.month201506.day20150619.subwayProjectV1;

import java.util.Scanner;

/**
 * Created by Administrator on 5/31/2015.
 */

//乘客类
public class Passenger {
    String name;
    WaterGlass waterGlass = new WaterGlass();
    Parcel parcel = new Parcel();
    String cardYesOrNo;
    SubwayCard subwayCard = new SubwayCard();
    TicketMachine ticketMachine = new TicketMachine();
    CardReader cardReader = new CardReader();
    MykiMachine mykiMachine = new MykiMachine();

    private Scanner input = new Scanner(System.in);

//    建立并输入新乘客对象信息
    public void setPassengerInfo(){
        Passenger passengerInfo = new Passenger();

        System.out.println("输入乘客信息：");

        System.out.println("姓名：");
        passengerInfo.name = input.next();

        System.out.println("是否有包（输入 有 或 没有）");
        if (input.next().equals("有")){
            System.out.println("包是不是危险品（输入 是 或 不是）");
            if (input.next().equals("是")) {
                parcel.dangerousOrNot = "危险品";
            }
            else {parcel.dangerousOrNot = "不是危险品";}
        }
        else {parcel = null;}


        System.out.println("是否有水杯（输入 有 或 没有）");
        if (input.next().equals("有")){
            System.out.println("水杯是不是危险品（输入 是 或 不是）");
            if (input.next().equals("是")) {
                waterGlass.dangerousOrNot = "危险品";
            }
            else {waterGlass.dangerousOrNot = "不是危险品";}
        }
        else {waterGlass = null;}

        System.out.println("是否有地铁卡（输入 有卡 或 没卡）");
        cardYesOrNo = input.next();
        if (cardYesOrNo.equals("有卡")){
            System.out.println("输入卡号");
            subwayCard.CardNumber = input.nextInt();

            System.out.println("输入余额");
            subwayCard.Balance = input.nextFloat();
            if(subwayCard.Balance < 2){
                mykiMachine.myki(subwayCard);
            }
        }
        else {subwayCard = null;}
    }



//    选择进站口
    public void selectStation(){
        MetroStation metroStation = new MetroStation();
//       地铁站视图
        System.out.println(metroStation.MetroStation().keySet());

        System.out.println("选择进站口：");
        subwayCard.inStation = input.next();
    }
    //    选择出站口
    public void selectionStation(){
        MetroStation metroStation = new MetroStation();
//       地铁站视图
        System.out.println(metroStation.MetroStation().keySet());
        System.out.println("选择出站口：");
        subwayCard.outStation = input.next();
    }

    public void consume() throws InterruptedException {
        if (cardYesOrNo.equals("没卡")) {
           ticketMachine.getNumber(subwayCard);
        }
        else{
           cardReader.IntoSubway(cardYesOrNo,subwayCard);
           cardReader.ComeOutSubway(cardYesOrNo,subwayCard);
        }
    }


}
